<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<title></title>
<script src="../easyui-1.3.5/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
function test() {
	$.ajax({
		type: "GET",
		url: "<c:url value='AServlet'/>",
		success: function(msg) {
			alert(msg);
		}
	});
}

function test1() {
	$.ajax('data/url')
		.done(function(response, statusText, jqXHR) {
			console.log(statusText);
		})
		.fail(function(jqXHR, statusText, error) {
			console.log(statusText);
		}), always(function() {
			console.log('I will always done.');
		});
}

function test3() {
	$.ajax({
		url: 't2.html',
		dataType: 'html',
		data: {
			d: 4
		}
	}).then(function() {
			console.log('success');
		},
		function() {
			console.log('failed');
		}).then(function() {
		console.log('second');
		return $.ajax({
			url: 'jquery-1.9.1.js',
			dataType: 'script'
		});
	}, function() {
		console.log('second f');
		return $.ajax({
			url: 'jquery-1.9.1.js',
			dataType: 'script'
		});
	}).then(function() {
		console.log('success2');
	}, function() {
		console.log('failed2');
	});
}

function get() {
	$.get("success.php", function(response) {
		console.log(response);
	})
}

var done = function(response, statusText, jqXHR) {
	console.log(statusText);
}
var fail = function(jqXHR, statusText, error) {
	console.log(statusText);
}
var always = function() {
	console.log('I will always done.');
}

function get2() {
	$.ajax('success.php')
		.done(done)
		.fail(fail)
		.always(always);
}

var success = function() {
	console.log('success');
}
var fail = function() {
	console.log('failed');
}

function get3() {
	$.ajax({
		url: 't2.html',
		dataType: 'html',
		data: {
			d: 4
		}
	}).then(success, fail).then(function() {
		console.log('second');
		return $.ajax({
			url: 'jquery-1.9.1.js',
			dataType: 'script'
		});
	}, function() {
		console.log('second f');
		return $.ajax({
			url: 'jquery-1.9.1.js',
			dataType: 'script'
		});
	}).then(function() {
		console.log('success2');
	}, function() {
		console.log('failed2');
	});
}
</script>
</head>

<body>
<input type="button" value="ajax点我" onclick="test()" />
<input type="button" value="$.get" onclick="get()" />
<input type="button" value="get2" onclick="get2()" />
<input type="button" value="get3" onclick="get3()" />
</body>

</html>